﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Zombicide.Model;
using System.Reflection;

namespace Zombicide.UI.WPF
{
    /// <summary>
    /// Logique d'interaction pour UCTile.xaml
    /// </summary>
    public partial class UCTile : UserControl
    {
        private const int NbrSquareByTile = 9;
        private MainWindow RefMainWindow;

        //public static readonly DependencyProperty TileProperty = DependencyProperty.Register("Tile", typeof(Tile), typeof(UCTile));

        //public Tile Tile
        //{
        //    get { return (Tile)GetValue(TileProperty); }
        //    set
        //    {
        //        SetValue(TileProperty, value);
        //        Init();
        //    }
        //}


        public UCTile()
        {
            InitializeComponent();
        }

        public UCTile(MainWindow mainWindow, Model.Tile tile)
        {
            InitializeComponent();

            RefMainWindow = mainWindow;
            //this.Tile = tile;
            //Init();
        }

        public void Init()
        {
            ////Image
            //ImageTile.Source = new BitmapImage(new Uri(Tile.ImageName, UriKind.Relative)); ;

            //Squares
            //foreach (var square in Tile.Squares)
            //{
            //    UCSquare newSquare = new UCSquare(RefMainWindow,square);

            //    var squareDelta = ImageTile.Width / NbrSquareByTile;
            //    newSquare.Width = squareDelta;
            //    newSquare.Height = squareDelta;
            //    Canvas.SetLeft(newSquare, squareDelta * square.X);
            //    Canvas.SetTop(newSquare, squareDelta * square.Y);

            //    CanvasTile.Children.Add(newSquare);
            //}
        }

        public void ActiveStartZone()
        {
            //foreach (var children in CanvasTile.Children)
            //{
            //    var square = children as UCSquare;
            //    if (square != null)
            //    {
            //        if (square.Square.IsEntry)
            //        {
            //            square.Highligth();
            //        }                    
            //    }
            //}
        }

        public void DesactivateHighlight()
        {
            //foreach (var children in CanvasTile.Children)
            //{
            //    var ucSquare = children as UCSquare;
            //    if (ucSquare != null)
            //    {
            //        if (ucSquare.Square.IsEntry)
            //        {
            //            ucSquare.DesactivateHighlight();
            //        }
            //    }
            //}
        }
    }
}
